From aec040c70969258e4f08394a786cbd9224f36796 Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Tue, 20 Oct 2015 09:49:01 -0600 Subject: [PATCH] Fix undefined variable in User::setNewpassword Follow up to I2c736ad to fix use of undefined `$id` variable. Change-Id: I04bd9c1dd7e3e1e63b8008d02df91cfb1ad971a3 --- includes/User.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/User.php b/includes/User.php index 0dfdfc4c14..6e52a1d980 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2478,6 +2478,11 @@ class User implements IDBAccessObject { * @param bool $throttle If true, reset the throttle timestamp to the present */ public function setNewpassword( $str, $throttle = true ) { + $id = $this->getId(); + if ( $id == 0 ) { + throw new LogicException( 'Cannot set new password for a user that is not in the database.' ); + } + $dbw = wfGetDB( DB_MASTER ); $passwordFactory = new PasswordFactory(); -- 2.20.1